package com.ice.project.datamining.config;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

public class PropertiesConfig {

	private static PropertiesConfig	instance	= null;

	private static Logger			log			= Logger.getLogger(PropertiesConfig.class.getName());

	/**
	 * @return a unique instance of PropertiesConfig
	 */
	public static PropertiesConfig getInstance() {
		if (instance == null) {
			instance = new PropertiesConfig();
		}
		return instance;
	}

	private Properties	properties;

	private PropertiesConfig() {
		properties = new Properties();
		try {
			properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"));
		} catch (FileNotFoundException e) {
			log.error(e.getMessage(), e);
		} catch (IOException e) {
			log.error(e.getMessage(), e);
		}
	}

	/**
	 * @param key
	 *            the key of the property searched
	 * @return the value of the property else NULL
	 */
	public String getPropertieValue(String key) {
		return properties.getProperty(key);
	}

}
